/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "ITEM_STATUS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ItemStatus.findAll", query = "SELECT i FROM ItemStatus i"),
    @NamedQuery(name = "ItemStatus.findByIdItemStatus", query = "SELECT i FROM ItemStatus i WHERE i.itemStatusPK.idItemStatus = :idItemStatus"),
    @NamedQuery(name = "ItemStatus.findByIdItem", query = "SELECT i FROM ItemStatus i WHERE i.itemStatusPK.idItem = :idItem"),
    @NamedQuery(name = "ItemStatus.findByIdProduct", query = "SELECT i FROM ItemStatus i WHERE i.itemStatusPK.idProduct = :idProduct"),
    @NamedQuery(name = "ItemStatus.findByIdBranchenterprise", query = "SELECT i FROM ItemStatus i WHERE i.itemStatusPK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "ItemStatus.findByIdEnterprise", query = "SELECT i FROM ItemStatus i WHERE i.itemStatusPK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "ItemStatus.findByName", query = "SELECT i FROM ItemStatus i WHERE i.name = :name"),
    @NamedQuery(name = "ItemStatus.findByDescription", query = "SELECT i FROM ItemStatus i WHERE i.description = :description"),
    @NamedQuery(name = "ItemStatus.findByInitdate", query = "SELECT i FROM ItemStatus i WHERE i.initdate = :initdate"),
    @NamedQuery(name = "ItemStatus.findByEnddate", query = "SELECT i FROM ItemStatus i WHERE i.enddate = :enddate")})
public class ItemStatus implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemStatusPK itemStatusPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "NAME")
    private String name;
    @Size(max = 45)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "INITDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date initdate;
    @Column(name = "ENDDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enddate;
    @JoinColumns({
        @JoinColumn(name = "ID_PRODUCT", referencedColumnName = "ID_PRODUCT", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ITEM", referencedColumnName = "ID_ITEM", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Item item;

    public ItemStatus() {
    }

    public ItemStatus(ItemStatusPK itemStatusPK) {
        this.itemStatusPK = itemStatusPK;
    }

    public ItemStatus(ItemStatusPK itemStatusPK, String name, Date initdate) {
        this.itemStatusPK = itemStatusPK;
        this.name = name;
        this.initdate = initdate;
    }

    public ItemStatus(BigInteger idItemStatus, BigInteger idItem, BigInteger idProduct, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.itemStatusPK = new ItemStatusPK(idItemStatus, idItem, idProduct, idBranchenterprise, idEnterprise);
    }

    public ItemStatusPK getItemStatusPK() {
        return itemStatusPK;
    }

    public void setItemStatusPK(ItemStatusPK itemStatusPK) {
        this.itemStatusPK = itemStatusPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getInitdate() {
        return initdate;
    }

    public void setInitdate(Date initdate) {
        this.initdate = initdate;
    }

    public Date getEnddate() {
        return enddate;
    }

    public void setEnddate(Date enddate) {
        this.enddate = enddate;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemStatusPK != null ? itemStatusPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemStatus)) {
            return false;
        }
        ItemStatus other = (ItemStatus) object;
        if ((this.itemStatusPK == null && other.itemStatusPK != null) || (this.itemStatusPK != null && !this.itemStatusPK.equals(other.itemStatusPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.ItemStatus[ itemStatusPK=" + itemStatusPK + " ]";
    }
    
}
